//
//  USChatRecallCell.m
//  us
//
//  Created by lhx on 2025/4/18.
//

#import "USChatRecallCell.h"

@implementation USChatRecallCell

- (void)setupView{
    [super setupView];
 

    self.recallLab = [UILabel new];
    self.recallLab.font = [UIFont systemFontOfSize:14];
    self.recallLab.textColor = UIColor.lightGrayColor;
    self.recallLab.textAlignment = NSTextAlignmentCenter;
    
    [self.messageContentView addSubview:self.recallLab];

    self.avatarImageView.hidden = YES;
    
}

- (void)setMessageViewModel:(USMessageViewModel *)messageViewModel{
    [super setMessageViewModel:messageViewModel];
 
    EMCustomMessageBody *body = (EMCustomMessageBody *)messageViewModel.message.body;
           
    
    if ([body.customExt.allKeys containsObject:@"recallBy"]) {
        NSString *userName = body.customExt[@"recallBy"];
        if ([userName isEqualToString:[[EMClient sharedClient] currentUsername]]) {
            self.recallLab.text = @"你撤回了一条消息";
        }else{
            self.recallLab.text = [NSString stringWithFormat:@"对方撤回了一条消息"];
        }
        
    }
    
}

- (void)updateLayout{

    [super updateLayout];
    

    [self.messageContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.avatarImageView);
        make.centerX.mas_equalTo(self.contentView);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-16);
    }];
    
    [self.recallLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.top.bottom.mas_offset(0);
        make.height.mas_equalTo(30);
    }];
    
}
 


@end
